package com.haitonghop.controls;

import java.util.HashMap;

public class DataCachedControl {
	
	public static final int TAM_DIEM_TOPIC_LIST = 1;
	public static final int TAM_DIEM__DETAIL_TOPIC_LIST = 2;
	public static final int GIRL_IMAGE_LIST = 3;
	public static final int TRUYENTRANH_CATEGORY = 4;
	public static final int TRUYENTRANH_CATEGORY_DETAIL = 5;
	public static final int TRUYENTRANH_CATEGORY_CHAPTER_LIST = 6;
	
	private static DataCachedControl instance = null;
	private HashMap<Integer, Object> dataCached;
	
	public DataCachedControl() {
		dataCached = new HashMap<Integer, Object>();
	}
	
	public static DataCachedControl getInstance(){
		if(instance == null) instance = new DataCachedControl();
		return instance;
	}
	
	public Object clearCached(int idCached){
		Integer key = new Integer(idCached);
		if(dataCached.containsKey(key)){
			return dataCached.remove(key);
		}
		return null;
	}
	
	public void putCached(int idCached, Object value){
		dataCached.put(new Integer(idCached), value);
	}
	
	public Object getCached(int idCached){
		Integer key = new Integer(idCached);
		if(dataCached.containsKey(key)){
			return dataCached.get(key);
		}
		return null;
	}
}
